USE [w1361192_SLSYJ]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Sectors](
	[SectorID] [int] IDENTITY(1,1) NOT NULL,
	[SectorName] [nvarchar](255) NULL,
PRIMARY KEY CLUSTERED 
(
	[SectorID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Categories](
	[CategoryID] [int] IDENTITY(1,1) NOT NULL,
	[CategoryName] [nvarchar](255) NULL,
	[CategoryGrossSalary] [decimal](19, 5) NULL,
PRIMARY KEY CLUSTERED 
(
	[CategoryID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Months](
	[MonthID] [int] IDENTITY(1,1) NOT NULL,
	[MonthNumber] [int] NULL,
	[MonthName] [nvarchar](255) NULL,
	[MonthCountOfDays] [int] NULL,
	[MonthWorkedDays] [int] NULL,
	[MonthAwaySickDays] [int] NULL,
	[MonthAwayAccidentDays] [int] NULL,
PRIMARY KEY CLUSTERED 
(
	[MonthID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Tasks](
	[TaskID] [int] IDENTITY(1,1) NOT NULL,
	[TaskName] [nvarchar](255) NULL,
	[TaskDescription] [nvarchar](255) NULL,
	[CategoryID] [int] NULL,
	[EmployeeCategoryID] [int] NULL,
PRIMARY KEY CLUSTERED 
(
	[TaskID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Employees](
	[EmployeeID] [int] IDENTITY(1,1) NOT NULL,
	[Name] [nvarchar](255) NULL,
	[Surname] [nvarchar](255) NULL,
	[FileNumber] [nvarchar](255) NULL,
	[DNInumber] [nvarchar](255) NULL,
	[CUILnumber] [nvarchar](255) NULL,
	[HiringDate] [datetime] NULL,
	[DateOfBirth] [datetime] NULL,
	[Salary] [decimal](19, 5) NULL,
	[RemunerativeSalary] [decimal](19, 5) NULL,
	[EmployeeCategoryId] [int] NULL,
	[CateorySectorId] [int] NULL,
	[SectorBranch] [int] NULL,
	[BankName] [nvarchar](255) NULL,
	[BankAccountNumber] [nvarchar](255) NULL,
	[BankCBUNumber] [nvarchar](255) NULL,
	[EmployeeSex] [int] NULL,
	[EmployeeMaritalStatus] [int] NULL,
	[HasAgreement] [bit] NULL,
	[CardNumber] [nvarchar](255) NULL,
	[Comments] [nvarchar](255) NULL,
	[Picture] [nvarchar](255) NULL,
PRIMARY KEY CLUSTERED 
(
	[EmployeeID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Years](
	[YearID] [int] IDENTITY(1,1) NOT NULL,
	[YearName] [nvarchar](255) NULL,
	[EmployeeID] [int] NULL,
PRIMARY KEY CLUSTERED 
(
	[YearID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Plus](
	[PlusID] [int] IDENTITY(1,1) NOT NULL,
	[PlusFormula] [nvarchar](255) NULL,
	[PlusCode] [nvarchar](255) NULL,
	[PlusName] [nvarchar](255) NULL,
	[PlusValue] [decimal](19, 5) NULL,
	[EmployeeID] [int] NULL,
PRIMARY KEY CLUSTERED 
(
	[PlusID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Parents](
	[ParentID] [int] IDENTITY(1,1) NOT NULL,
	[ParentName] [nvarchar](255) NULL,
	[ParentDNI] [nvarchar](255) NULL,
	[ParentAge] [int] NULL,
	[EmployeeID] [int] NULL,
PRIMARY KEY CLUSTERED 
(
	[ParentID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[EmployeeCategory](
	[EmployeeCategoryID] [int] IDENTITY(1,1) NOT NULL,
	[CategoryId] [int] NULL,
PRIMARY KEY CLUSTERED 
(
	[EmployeeCategoryID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO

ALTER TABLE [dbo].[EmployeeCategory]  WITH CHECK ADD  CONSTRAINT [FKA24F33726F632F28] FOREIGN KEY([CategoryId])
REFERENCES [dbo].[Categories] ([CategoryID])
GO
ALTER TABLE [dbo].[EmployeeCategory] CHECK CONSTRAINT [FKA24F33726F632F28]
GO

ALTER TABLE [dbo].[Employees]  WITH CHECK ADD  CONSTRAINT [FKBF2D7FFE9E73ED3] FOREIGN KEY([EmployeeCategoryId])
REFERENCES [dbo].[EmployeeCategory] ([EmployeeCategoryID])
GO
ALTER TABLE [dbo].[Employees] CHECK CONSTRAINT [FKBF2D7FFE9E73ED3]
GO

ALTER TABLE [dbo].[Employees]  WITH CHECK ADD  CONSTRAINT [FKBF2D7FFFD10BD47] FOREIGN KEY([CateorySectorId])
REFERENCES [dbo].[Sectors] ([SectorID])
GO
ALTER TABLE [dbo].[Employees] CHECK CONSTRAINT [FKBF2D7FFFD10BD47]
GO

ALTER TABLE [dbo].[Parents]  WITH CHECK ADD  CONSTRAINT [FKEF0FB61B121809CE] FOREIGN KEY([EmployeeID])
REFERENCES [dbo].[Employees] ([EmployeeID])
GO
ALTER TABLE [dbo].[Parents] CHECK CONSTRAINT [FKEF0FB61B121809CE]
GO

ALTER TABLE [dbo].[Plus]  WITH CHECK ADD  CONSTRAINT [FKBBA077D1121809CE] FOREIGN KEY([EmployeeID])
REFERENCES [dbo].[Employees] ([EmployeeID])
GO
ALTER TABLE [dbo].[Plus] CHECK CONSTRAINT [FKBBA077D1121809CE]
GO

ALTER TABLE [dbo].[Tasks]  WITH CHECK ADD  CONSTRAINT [FKD3FB4CDE6F632F28] FOREIGN KEY([CategoryID])
REFERENCES [dbo].[Categories] ([CategoryID])
GO
ALTER TABLE [dbo].[Tasks] CHECK CONSTRAINT [FKD3FB4CDE6F632F28]
GO

ALTER TABLE [dbo].[Tasks]  WITH CHECK ADD  CONSTRAINT [FKD3FB4CDEE9E73ED3] FOREIGN KEY([EmployeeCategoryID])
REFERENCES [dbo].[EmployeeCategory] ([EmployeeCategoryID])
GO
ALTER TABLE [dbo].[Tasks] CHECK CONSTRAINT [FKD3FB4CDEE9E73ED3]
GO

ALTER TABLE [dbo].[Years]  WITH CHECK ADD  CONSTRAINT [FK9F2CAEE5121809CE] FOREIGN KEY([EmployeeID])
REFERENCES [dbo].[Employees] ([EmployeeID])
GO
ALTER TABLE [dbo].[Years] CHECK CONSTRAINT [FK9F2CAEE5121809CE]
GO

ALTER TABLE [dbo].[Years]  WITH CHECK ADD  CONSTRAINT [FK9F2CAEE580EBE7F0] FOREIGN KEY([YearID])
REFERENCES [dbo].[Years] ([YearID])
GO
ALTER TABLE [dbo].[Years] CHECK CONSTRAINT [FK9F2CAEE580EBE7F0]
GO
